<?php echo $header; ?>
<style>
.center{
	padding: 10px 0 !important;
	vertical-align:center;
}
#blue:hover td {
    color: #000000;
}
#blue td {
    color: #D3D3D3;
}
.list tbody tr:hover td {
    background-color: #FFFFCB;
}
</style>
<?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content"><?php echo $content_top; ?>
  <div class="box">
    <div class="heading">
      <h1><img src="view/image/customer.png" alt="" />CHI TIẾT HOA HỒNG</h1>
    </div>
    <div class="content">
	 <!--  <p style="text-align:right"> Thanh Toán Trong Tháng: <span style="color:#003A88;font-weight:bold;">[<?php echo $totalbaotrotrongthang + $totaltuvantrongthang + $totaltuvan2trongthang + $totalquanlytrongthang;?>]</span> - Tiền giao dịch: <span style="color:blue;font-weight:bold;">[<?php echo $diemchuyen;?>]</span> - Tổng Cộng: <span style="color:red;font-weight:bold;">[ <?php echo $totalbaotrotrongthang + $totaltuvantrongthang + $totaltuvan2trongthang + $totalquanlytrongthang + $diemchuyen;?>]</span></p>-->
	 <!-- <p style="text-align:right"><a class="button" Onclick="Chuyendiemgiaodich();">Chuyển điểm giao dịch</a></p>-->
	  
      <form action="" method="post" enctype="multipart/form-data" id="form">
        <table class="list">
          <thead>
		  <p style="font-weight:bold;font-size: 16px;">I. Hoa hồng tổng cộng: </p>
            <tr>
              <td class="center">Họ tên</td>  
			  <td class="center">Mã thành viên</td>
			  <td class="center">Tiền đăng nhập</td>  
			  <td class="center">Tiền thu lần 2</td>
              <td class="center">Tổng HH trực tiếp<br>
				<span>[Chuyển]</span> 
				<span style="color:red">[Chưa Chuyển]</span> 	
			</td>
			<td class="center">Tổng HH gián tiếp<br>
				<span>[Chuyển]</span> 
				<span style="color:red">[Chưa Chuyển]</span> 	
			</td>
			<td class="center">Tổng cộng<br>
				<span>[Chuyển]</span> 
				<span style="color:red">[Chưa Chuyển]</span> 	
			</td>	
            </tr>
          </thead>
         <tbody>
		  <tr>
			  <td class="center"><?php echo $name; ?></td>
              <td class="center"><?php echo $madn; ?></td>
			  <td class="center"><?php echo $money; ?></td>
              <td class="center"><?php echo $money2; ?></td>
              <td class="center"><p><?php echo $totalbaotro; ?></p>
				<span style="font-weight:bold;">[<?php echo $totalbaotronhan;?>]</span> 
				<span style="color:red;font-weight:bold;">[<?php echo $totalbaotrochuanhan;?>]</span> 
			  </td>
			   <td class="center"><p><?php echo $totaltuvan; ?></p>
				<span style="font-weight:bold;">[<?php echo $totaltuvannhan;?>]</span> 
				<span style="color:red;font-weight:bold;">[<?php echo $totaltuvanchuanhan;?>]</span> 
			  </td>
			   
			    <td class="center"><p><?php echo $total ; ?></p>
				<span style="font-weight:bold;">[<?php echo $totalnhan ?>]</span> 
				<span style="color:red;font-weight:bold;">[<?php echo $totalchuanhan ;?>]</span> 
			  </td>
			  </tr>
          </tbody>
        </table>

		<table class="list">
          <thead>
		  <p style="font-weight:bold;font-size: 16px;">II. Chi tiết hoa hồng trực tiếp:</p>

		  <p style="font-weight:bold;color:#000">  Tổng: <span style="color:red;font-weight:bold;font-size:16px">[<?php echo $totalbaotro; ?>] </span> -  
				Chuyển: <span style="font-weight:bold;font-size:16px"> [<?php echo $totalbaotronhan;?>] </span> 
				 - Chưa Chuyển: <span style="color:#003A88;font-weight:bold;font-size:16px"> [<?php echo $totalbaotrochuanhan;?>] </span>
			  </p>
            <tr>
              <td class="center">STT</td>  
              <td class="center">Mã phát</td>  
			  <td class="center">Họ tên phát</td>
			  <td class="center">DT</td>
			   <td class="center">Email</td>		
              <td class="center">Ngày tham gia</td>
			<td class="center">Tiền hoa hồng</td>
			<td class="center"><span>[Chuyển]</span> 
				<span style="color:red">[Chưa Chuyển]</span> 	
			</td>
			<td class="center">Ngày Chuyển</td>
            </tr>
          </thead>
         <tbody>
		  <?php if ($hhbaotro) { $i = Count($hhbaotro); ?>
			
            <?php foreach ($hhbaotro as $customer) { ?>
			  <?php if((int)$customer['status'] == 1){?>
					<tr>
				<?php } else {?>
						<tr style="border-left:5px solid #1900ff" >
				<?php }?>	
               <td class="center"><?php echo $i; ?></td>
			   <td class="center"><?php echo $customer['madn']; ?></td>
			   <td class="center"><?php echo $customer['name']; ?></td>
               <td class="center"><?php echo $customer['telephone']; ?></td>
			   <td class="center"><?php echo $customer['email']; ?></td>
               <td class="center"><?php echo $customer['date_join']; ?></td>
			   <td class="center"><?php echo $customer['hoahong']; ?></td>
			   <td class="center">
				<?php if((int)$customer['status'] == 1){?>
					<span style="color:red;">Đã Chuyển</span>
				<?php } else {?>
					Chưa Chuyển
				<?php }?>	
			   </td>
			   <td class="center"><?php echo $customer['date_added']; ?></td>
			   
            </tr>
            <?php $i--; } ?>
            <?php } else { ?>
            <tr>
              <td class="center" colspan="11"></td>
            </tr>
            <?php } ?>
          </tbody>
        </table>
		
		<table class="list">
          <thead>
		  <p style="font-weight:bold;font-size: 16px;">V. Chi tiết hoa hồng gián tiếp:</p>
		  <p style="font-weight:bold;color:#000">  Tổng: <span style="color:red;font-weight:bold;font-size:16px">[<?php echo $totaltuvan; ?>] </span> -  
				Chuyển: <span style="font-weight:bold;font-size:16px"> [<?php echo $totaltuvannhan;?>] </span> 
				 - Chưa Chuyển: <span style="color:#003A88;font-weight:bold;font-size:16px"> [<?php echo $totaltuvanchuanhan;?>] </span>
			  </p>
            <tr>
              <td class="center">STT</td>  
              <td class="center">Mã phát</td>  
			  <td class="center">Họ tên phát</td>
			 <td class="center">DT</td>
			   <td class="center">Email</td>
              <td class="center">Ngày tham gia</td>
			<td class="center">Tiền hoa hồng</td>
			<td class="center"><span>[Chuyển]</span> 
				<span style="color:red">[Chưa Chuyển]</span> 	
			</td>
			<td class="center">Ngày Chuyển</td>
            </tr>
          </thead>
         <tbody>
		  <?php if ($hhtuvan) { $i = 1; ?>
			
            <?php foreach ($hhtuvan as $customer) { ?>
			<?php if((int)$customer['status'] == 1){?>
					<tr>
				<?php } else {?>
						<tr style="border-left:5px solid #1900ff" >
				<?php }?>	
              <td class="center"><?php echo $i; ?></td>
			   <td class="center"><?php echo $customer['madn']; ?></td>
			   <td class="center"><?php echo $customer['name']; ?></td>
			<td class="center"><?php echo $customer['telephone']; ?></td>
				<td class="center"><?php echo $customer['email']; ?></td>
              <td class="center"><?php echo $customer['date_join']; ?></td>
			  <td class="center"><?php echo $customer['hoahong']; ?></td>
			   <td class="center">
				<?php if((int)$customer['status'] == 1){?>
					<span style="color:red;">Đã Chuyển</span>
				<?php } else {?>
					Chưa Chuyển
				<?php }?>	
			   </td>
			  <td class="center"><?php echo $customer['date_added']; ?></td>
            </tr>
            <?php $i++; } ?>
            <?php } else { ?>
            <tr>
              <td class="center" colspan="11"></td>
            </tr>
            <?php } ?>
          </tbody>
        </table>
		
      </form>
    </div>
  </div>
  <?php echo $content_bottom; ?></div>
<script type="text/javascript"><!--

function Chuyendiemgiaodich(){
	$('.chuyendiem').slideDown();
	$('.edit_pass').slideUp();
}
function Close1(){
	location.reload();
}

function GetCustomer(){
	var user_nhan = $('#manhan').val();
	if(!user_nhan){
			alert('Nhập mã số người nhận');
		} else {
			$.ajax({
				url:  'index.php?route=account/user/GetCustomer',
				type: 'post',
				data: 'user_nhan=' + user_nhan,
				dataType: 'json',		
				beforeSend: function() {
					$('body').css('opacity', 0.5);
				},
				complete: function() {
					$('body').css('opacity', 1);
				},		
				success: function(json) {
					if(json['error']){
						alert(json['error']);
						$('#info_cus').html('');
						$('#user_nhan').val('');
					}
					if(json['success']){
						$('#user_nhan').val(json['success']['customer_id']);
						var html ='';
						html += '<br><span style="margin-right:25px;color:red">Mã số người nhận </span><span id="madn" style="color:#000;">'+ json['success']['madn'] + '</span><br>';
						html += '<span style="margin-right:35px;color:red">Tên người nhận </span><span id="madn" style="color:#000;">'+ json['success']['firstname'] + '</span><br>';
						html += '<span style="margin-right:55px;color:red">Số điện thoại </span><span id="madn" style="color:#000;">'+ json['success']['telephone'] + '</span><br>';
						html += '<span style="margin-right:85px;color:red">Địa chỉ </span><span id="madn" style="color:#000;">'+ json['success']['diachi'] + '</span><br>';
						$('#info_cus').html(html);
						$('#buttonxacnhan').css('display','inline-block');
						$('#buttonhuy').css('display','inline-block');
						$('#confirm').html('');
					$('#manhan').attr("disabled", "disabled");
						
					}
					
					
				}
			});
		}
}
function XacNhan(){
		var moneyuser = parseInt(<?php echo $totalbaotrochuanhan + $totaltuvanchuanhan + $totaltuvanlan2chuanhan + $totalquanlychuanhan + $diemchuyen;?>);
		var moneychuyen = parseInt($('#moneychuyen').val());
		var comment = $('#comment').val();
		if(moneychuyen > moneyuser){
			alert('Số điểm bạn chuyển lớn hơn số điểm bạn hiện có');
		}else if(!moneychuyen){
			alert('Nhập số điểm bạn cần chuyển');
		}else {
			var html = 'Bạn đồng ý chuyển điểm cho '+ $('#manhan').val() + ' không? ';
			$('#confirm').html(html);
			$('#buttonchuyendiem').css('display','inline-block');
			$('#buttonhuy').css('display','inline-block');
			$('#buttonxacnhan').css('display','none');
		}	
	}

	function ChuyenDiem(){
		var user_chuyen = <?php echo $customer_id;?>;
		var moneyuser = parseInt(<?php echo $totalbaotrochuanhan + $totaltuvanchuanhan + $totaltuvanlan2chuanhan + $totalquanlychuanhan;?>);
		var user_nhan = $('#user_nhan').val();
		var moneychuyen = parseInt($('#moneychuyen').val());
		var comment = $('#comment').val();
			$.ajax({
				url:  'index.php?route=account/user/ChuyenDiemGiaoDich',
				type: 'post',
				data: 'user_chuyen=' + user_chuyen + '&user_nhan=' + user_nhan + '&moneychuyen=' + moneychuyen + '&comment=' + comment,
				dataType: 'json',		
				beforeSend: function() {
					$('body').css('opacity', 0.5);
				},
				complete: function() {
					$('body').css('opacity', 1);
				},		
				success: function(json) {
					alert('Bạn đã chuyển điểm thành công');
					location.reload();
				}
			});	
	}

//--></script>

<?php echo $footer; ?> 